﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace WpfDataEntry1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ICollectionView _view;
        List<StudentInfo> students = new List<StudentInfo>();
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //List<string> list=new List<string>();
            //list.Add("Data1");
            //list.Add("Data2");
            //list.Add("Data3");
            //XDocument doc = new XDocument(new XElement("file", 
            //    new XElement("name", new XAttribute("filename", "sample")), 
            //    new XElement("date", new XAttribute("modified", DateTime.Now)), 
            //    new XElement("info", list.Select(x => new XElement("data", new XAttribute("value", x))))));


            //XElement element= doc.Element("file");


            
            students.Add(new StudentInfo { RollNo = 101, Name = "Arun", Age = 22 });
            students.Add(new StudentInfo { RollNo = 102, Name = "Barun", Age = 21 });
            students.Add(new StudentInfo { RollNo = 103, Name = "Kiran", Age = 23 });

            this.DataContext = students;
            _view = CollectionViewSource.GetDefaultView(students);


        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            _view.MoveCurrentToFirst();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            _view.MoveCurrentToNext();
            if (_view.IsCurrentAfterLast)
                _view.MoveCurrentToPrevious();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (_view.CurrentPosition > 0)
                _view.MoveCurrentToPrevious();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            _view.MoveCurrentToLast();
        }

    }

}
